package com.helloworld.common.dao.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import com.helloworld.common.dao.CommonCodeDao;

@Repository(value = "commonCodeDao")
public class CommonCodeDaoImpl extends SqlSessionDaoSupport implements CommonCodeDao {

	@Override
	public Map<String, List<Map<String, String>>> list(String gp) {
		if (gp == null) { return null; }
		
		String[] arr = gp.split(",");
		
		Map<String, List<Map<String, String>>> result = new HashMap<String, List<Map<String, String>>>();
		
		for (String str : arr) {
			List<Map<String, String>> group = new ArrayList<Map<String, String>>();
			
			Map<String, String> map = null;
			map = new HashMap<String, String>();
			map.put("group", str); map.put("key", str + "01"); map.put("value", str + ",value 1");
			group.add(map);
			
			map = new HashMap<String, String>();
			map.put("group", str); map.put("key", str + "02"); map.put("value", str + ",value 2");
			group.add(map);

			map = new HashMap<String, String>();
			map.put("group", str); map.put("key", str + "03"); map.put("value", str + ",value 3");
			group.add(map);

			map = new HashMap<String, String>();
			map.put("group", str); map.put("key", str + "04"); map.put("value", str + ",value 4");
			group.add(map);
			
			result.put(str, group);
		}
		
		return result;
	}

}
